<?php
// ------------------------------------------------------------------------
// |@Author       : Jarmin <edshop@qq.com>
// |@----------------------------------------------------------------------
// |@Date         : 2022-10-24 10:58:18
// |@----------------------------------------------------------------------
// |@LastEditTime : 2023-05-14 14:53:12
// |@----------------------------------------------------------------------
// |@LastEditors  : Jarmin <jarmin@ladmin.cn>
// |@----------------------------------------------------------------------
// |@Description  : 
// |@----------------------------------------------------------------------
// |@FilePath     : Index.php
// |@----------------------------------------------------------------------
// |@Copyright (c) 2023 http://www.ladmin.cn   All rights reserved. 
// ------------------------------------------------------------------------
namespace app\api\controller;

use think\admin\Controller;

class Index extends Controller
{
    public function index()
    {
        return $this->error(lang('common.get_request_error'),null,'002');
    }

    /**
     * 获取token
     */
    public function token()
    {
        if ($this->request->isGet()) {
            return $this->error(lang('common.get_request_error'),null,'002');
        } elseif ($this->request->isPost()) {
            $data = [
                'token'         =>  "SCUI.Administrator.Auth",
                'userInfo'      =>  [
                    'userId'    =>  1,
                    'userName'  =>  'Administrator',
                    'dashboard' =>  0,
                    'role'      =>  ["SA", "admin", "Auditor"],
                ],
            ];
            return $this->success('',$data,200);
        }
    }

    // 获取菜单信息
    public function menu()
    {
        if ($this->request->isGet()) {
            $data = [
                'menu' => [
                    [
                        'name' => 'home',
                        'path' => '/home',
                        'meta' => [
                            'title'  => '首页',
                            'icon'   => 'el-icon-eleme-filled',
                            'type'   => 'menu',
                        ],
                        'children' => [
                            [
                                'name' => 'dashboard',
                                'path' => '/dashboard',
                                'meta' => [
                                    'title'  => '控制台',
                                    'icon'   => 'el-icon-menu',
                                    'affix'  => true,
                                ],
                                'component' => 'home',
                            ]
                        ],
                    ],
                    [
                        'name' => 'setting',
                        'path' => '/setting',
                        'meta' => [
                            'title'  => '配置',
                            'icon'   => 'el-icon-setting',
                            'type'   => 'menu',
                        ],
                        'children' => [
                            [
                                'name' => 'user',
                                'path' => '/setting/user',
                                'meta' => [
                                    'title'  => '用户管理',
                                    'icon'   => 'el-icon-user-filled',
                                    'type'   => 'menu',
                                ],
                                'component' => 'setting/user',
                            ],
                            [
                                'name' => 'role',
                                'path' => '/setting/role',
                                'meta' => [
                                    'title'  => '角色管理',
                                    'icon'   => 'el-icon-notebook',
                                    'type'   =>'menu',
                                ],
                                'component' =>'setting/role',
                            ],
                            [
                                'name' => 'dept',
                                'path' => '/setting/dept',
                                'meta' => [
                                    'title'  => '部门管理',
                                    'icon'   => 'sc-icon-organization',
                                    'type'   =>'menu',
                                ],
                                'component' =>'setting/dept',
                            ],
                            [
                                'name' => 'menu',
                                'path' => '/setting/menu',
                                'meta' => [
                                    'title'  => '菜单管理',
                                    'icon'   => 'el-icon-fold',
                                    'type'   =>'menu',
                                ],
                                'component' =>'setting/menu',
                            ],
                        ],
                    ]
                ],
                'permissions' => [
                    "list.add",
                    "list.edit",
                    "list.delete",
                    "user.add",
                    "user.edit",
                    "user.delete",
                ],
                'dashboardGrid' => [
                    "welcome",
                    "ver",
                    "time",
                    "progress",
                    "echarts",
                    "about",
                ]
            ];
            return $this->success('',$data,200);
        } elseif ($this->request->isPost()) {
            return $this->error(lang('common.post_request_error'),null,'002');
        }
    }

    // 获取版本信息
    public function ver()
    {
        if ($this->request->isGet()) {
            return $this->success('','1.6.9',200);
        } elseif ($this->request->isPost()) {
            return $this->error(lang('common.post_request_error'),null,'002');
        }
    }
}
